function removeXSS(s) {
    var pattern = new RegExp("[<>’”]")
    var rs = "";
    for (var i = 0; i < s.length; i++) {
        rs = rs + s.substr(i, 1).replace(pattern, '');
    }
    return rs;
}

if (bowser.mobile) {
    var url = location.href.replace(/(zh-cn|zh-hk|en-us)/,'mobile/$1');
    var hash = '';
    url = removeXSS(url);
    if (url.indexOf("index.html") == -1 && url.indexOf("company.html") == -1 && url.indexOf("culture.html") == -1 && url.indexOf(
            "system.html") == -1 && url.indexOf("dynamic_timeline.html") == -1 && url.indexOf("news.html") == -1) {
        url = url + "/mobile/index.html"
    } else {
        url = url.replace(/(index|company|culture|system|dynamic_timeline|news)\.html/, function($1) {
            var names = ['index.html', 'company.html', 'culture.html', 'system.html', 'dynamic_timeline.html',
                'news.html'
            ];
            var count = names.length;
            for (var i = 0; i < count; i++) {
                if (names[i] === $1) {
                    hash = names[i];
                    break;
                }
            }
            return 'mobile/' + hash;
        });
    }
    url = removeXSS(url);
    location.href = url;
}
